<template>
	<view class="box">
		<view @tap="gotodetail(item)" class="item" v-for="(item,index) in items" v-key='item._id'>
			<image src="/static/image/logo.png"></image>
			<view class="mid">
				<view>{{item.title}}</view>
				<view>网商价：<span style='color: red;'>￥{{item.price}}</span></view>
			</view>
			<text @tap="quxiaoshoucang(item._id)" class="cuIcon-deletefill text-blue" style="font-size: 25px;line-height: 10vh;"></text>
		</view>
	</view>
</template>

<script>
	const db=wx.cloud.database()
	const _=wx.command
	export default {
		name:"MyZhuji",
		data() {
			return {
			};
		},
		props:{
			items:{
				type:Array,
				required:true
			}
		},
		methods:{
			gotodetail(item){

				uni.navigateTo({
					url:'/pages/index/recommend/details/details?data='+JSON.stringify(item)
				})
			},
			quxiaoshoucang(id){
				let index= getApp().globalData.userdata.zhuji.indexOf(id)
				getApp().globalData.userdata.zhuji.splice(index,1)
				db.collection('user').where({
					_openid:getApp().globalData.userdata._openid
				}).update({
					data:{
						zhuji:getApp().globalData.userdata.zhuji
					}
				}).then(res=>{
					this.$emit('zhujishuaxin')
				})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	
.item{
	background-color: white;
	display: flex;
	flex-direction: row;
	height:14vh;
	padding:2vh 2vw;
	border-bottom:1px solid #F1F1F1;
	image{
		height: 10vh;
		width: 15vw;
	}
	.mid{
		width: 60vw;
		margin-left: 5vw;
		view{
			line-height: 5vh;
		}
	}
}
</style>
